﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SimpleProject.Models;

namespace SimpleProject.Controllers
{
    public class UsersController : Controller
    {
        dbDataContext Db = new dbDataContext();

        [HttpGet]
        public ActionResult Index()
        {
            ViewBag.Title = "Kullanıcı Listesi";
            var UserList = Db.Users.ToList();
            return View(UserList);
        }
        [HttpGet]
        public ActionResult Create()
        {
            ViewBag.Title = "Kullanıcı Oluştur";
            return View();
        }
        [HttpPost ]
        public ActionResult Create(User User)
        {
            if (ModelState.IsValid)
            {
                Db.Users.InsertOnSubmit(User);
                Db.SubmitChanges();
                return RedirectToAction("Index");
            }
            return View(User);
        }

    }
}
